
from SBFI import func_sbf
import numpy as np
def gra(S,data):
    label_need=data.keys()[:]
    data1=data[label_need].values
    print(data1)
    [m,n]=data1.shape
    data2=data1.astype('float')
    data3=data2
    # 结果显示到0.002到1
    ymin=0.002
    ymax=1
    for j in range(0,n):
        d_max=max(data2[:,j])
        d_min=min(data2[:,j])
        data3[:,j]=(ymax-ymin)*(data2[:,j]-d_min)/(d_max-d_min)+ymin

    for i in range(0,n-1):
        data3[:,i]=np.abs(data3[:,i]-data3[:,n-1])
    data4=data3[:,0:n-1]
    d_max=np.max(data4)
    d_min=np.min(data4)
    a=0.5
    data4=(d_min+a*d_max)/(data4+a*d_max)
    res=np.var(data4, axis=0)
    sorted_nums = sorted(enumerate(res), key=lambda x: x[1])
    idx = [i[0] for i in sorted_nums]
    func_sbf(S, idx, data)


if __name__ == '__main__':
    gra()